Imports System.Text
Public Class frmUsers
    Inherits System.Windows.Forms.Form
    Dim Tuser As Integer = 0
    Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents cmdSave As DevComponents.DotNetBar.ButtonX
    Friend WithEvents cmdExit As DevComponents.DotNetBar.ButtonX
    Friend WithEvents cmdRoles As DevComponents.DotNetBar.ButtonX
    Friend WithEvents cmdDelete As DevComponents.DotNetBar.ButtonX
    Friend WithEvents GroupPanel1 As DevComponents.DotNetBar.Controls.GroupPanel
    Dim uOptions As frmUserSecurity

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents dgShowroom As System.Windows.Forms.DataGrid
    Friend WithEvents tbPassword As System.Windows.Forms.TextBox
    Friend WithEvents tbUser As System.Windows.Forms.TextBox
    Friend WithEvents tbName As System.Windows.Forms.TextBox
    Friend WithEvents cbActive As System.Windows.Forms.CheckBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents rbUser As System.Windows.Forms.RadioButton
    Friend WithEvents rbAdmin As System.Windows.Forms.RadioButton
    Friend WithEvents lblNew As System.Windows.Forms.Label
    Friend WithEvents dgUsers As System.Windows.Forms.DataGrid
    Friend WithEvents Label7 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Label7 = New System.Windows.Forms.Label()
        Me.dgUsers = New System.Windows.Forms.DataGrid()
        Me.lblNew = New System.Windows.Forms.Label()
        Me.GroupBox1 = New System.Windows.Forms.GroupBox()
        Me.rbAdmin = New System.Windows.Forms.RadioButton()
        Me.rbUser = New System.Windows.Forms.RadioButton()
        Me.Label6 = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.cbActive = New System.Windows.Forms.CheckBox()
        Me.dgShowroom = New System.Windows.Forms.DataGrid()
        Me.Label5 = New System.Windows.Forms.Label()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.tbPassword = New System.Windows.Forms.TextBox()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.tbUser = New System.Windows.Forms.TextBox()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.tbName = New System.Windows.Forms.TextBox()
        Me.ComboBox1 = New System.Windows.Forms.ComboBox()
        Me.Label8 = New System.Windows.Forms.Label()
        Me.cmdSave = New DevComponents.DotNetBar.ButtonX()
        Me.cmdExit = New DevComponents.DotNetBar.ButtonX()
        Me.cmdRoles = New DevComponents.DotNetBar.ButtonX()
        Me.cmdDelete = New DevComponents.DotNetBar.ButtonX()
        Me.GroupPanel1 = New DevComponents.DotNetBar.Controls.GroupPanel()
        CType(Me.dgUsers, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.GroupBox1.SuspendLayout()
        CType(Me.dgShowroom, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.GroupPanel1.SuspendLayout()
        Me.SuspendLayout()
        '
        'Label7
        '
        Me.Label7.AutoSize = True
        Me.Label7.BackColor = System.Drawing.Color.Transparent
        Me.Label7.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label7.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label7.Location = New System.Drawing.Point(414, 7)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(82, 18)
        Me.Label7.TabIndex = 119
        Me.Label7.Text = "List of Users"
        '
        'dgUsers
        '
        Me.dgUsers.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.dgUsers.CaptionVisible = False
        Me.dgUsers.DataMember = ""
        Me.dgUsers.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgUsers.Location = New System.Drawing.Point(422, 54)
        Me.dgUsers.Name = "dgUsers"
        Me.dgUsers.RowHeadersVisible = False
        Me.dgUsers.Size = New System.Drawing.Size(291, 401)
        Me.dgUsers.TabIndex = 118
        '
        'lblNew
        '
        Me.lblNew.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblNew.ForeColor = System.Drawing.Color.Firebrick
        Me.lblNew.Location = New System.Drawing.Point(563, 359)
        Me.lblNew.Name = "lblNew"
        Me.lblNew.Size = New System.Drawing.Size(108, 14)
        Me.lblNew.TabIndex = 116
        '
        'GroupBox1
        '
        Me.GroupBox1.BackColor = System.Drawing.Color.Transparent
        Me.GroupBox1.Controls.Add(Me.rbAdmin)
        Me.GroupBox1.Controls.Add(Me.rbUser)
        Me.GroupBox1.Location = New System.Drawing.Point(134, 189)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(174, 69)
        Me.GroupBox1.TabIndex = 115
        Me.GroupBox1.TabStop = False
        '
        'rbAdmin
        '
        Me.rbAdmin.AutoSize = True
        Me.rbAdmin.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.rbAdmin.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.rbAdmin.Location = New System.Drawing.Point(20, 42)
        Me.rbAdmin.Name = "rbAdmin"
        Me.rbAdmin.Size = New System.Drawing.Size(112, 22)
        Me.rbAdmin.TabIndex = 6
        Me.rbAdmin.Text = "Administrator"
        '
        'rbUser
        '
        Me.rbUser.AutoSize = True
        Me.rbUser.Checked = True
        Me.rbUser.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.rbUser.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.rbUser.Location = New System.Drawing.Point(20, 16)
        Me.rbUser.Name = "rbUser"
        Me.rbUser.Size = New System.Drawing.Size(54, 22)
        Me.rbUser.TabIndex = 5
        Me.rbUser.TabStop = True
        Me.rbUser.Text = "User"
        '
        'Label6
        '
        Me.Label6.AutoSize = True
        Me.Label6.BackColor = System.Drawing.Color.Transparent
        Me.Label6.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label6.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label6.Location = New System.Drawing.Point(12, 191)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(36, 18)
        Me.Label6.TabIndex = 114
        Me.Label6.Text = "Role"
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.BackColor = System.Drawing.Color.Transparent
        Me.Label2.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label2.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label2.Location = New System.Drawing.Point(12, 130)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(46, 18)
        Me.Label2.TabIndex = 113
        Me.Label2.Text = "Status"
        '
        'cbActive
        '
        Me.cbActive.AutoSize = True
        Me.cbActive.BackColor = System.Drawing.Color.Transparent
        Me.cbActive.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cbActive.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.cbActive.Location = New System.Drawing.Point(134, 129)
        Me.cbActive.Name = "cbActive"
        Me.cbActive.Size = New System.Drawing.Size(65, 22)
        Me.cbActive.TabIndex = 4
        Me.cbActive.Text = "Active"
        Me.cbActive.UseVisualStyleBackColor = False
        '
        'dgShowroom
        '
        Me.dgShowroom.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.dgShowroom.CaptionVisible = False
        Me.dgShowroom.DataMember = ""
        Me.dgShowroom.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgShowroom.Location = New System.Drawing.Point(137, 291)
        Me.dgShowroom.Name = "dgShowroom"
        Me.dgShowroom.RowHeadersVisible = False
        Me.dgShowroom.Size = New System.Drawing.Size(265, 164)
        Me.dgShowroom.TabIndex = 7
        '
        'Label5
        '
        Me.Label5.AutoSize = True
        Me.Label5.BackColor = System.Drawing.Color.Transparent
        Me.Label5.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label5.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label5.Location = New System.Drawing.Point(15, 265)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(110, 18)
        Me.Label5.TabIndex = 109
        Me.Label5.Text = "Company Access"
        '
        'Label4
        '
        Me.Label4.AutoSize = True
        Me.Label4.BackColor = System.Drawing.Color.Transparent
        Me.Label4.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label4.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label4.Location = New System.Drawing.Point(12, 95)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(67, 18)
        Me.Label4.TabIndex = 107
        Me.Label4.Text = "Password"
        '
        'tbPassword
        '
        Me.tbPassword.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tbPassword.Location = New System.Drawing.Point(138, 119)
        Me.tbPassword.MaxLength = 10
        Me.tbPassword.Name = "tbPassword"
        Me.tbPassword.PasswordChar = Global.Microsoft.VisualBasic.ChrW(42)
        Me.tbPassword.Size = New System.Drawing.Size(174, 26)
        Me.tbPassword.TabIndex = 3
        Me.tbPassword.UseSystemPasswordChar = True
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.BackColor = System.Drawing.Color.Transparent
        Me.Label3.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label3.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label3.Location = New System.Drawing.Point(12, 29)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(52, 18)
        Me.Label3.TabIndex = 105
        Me.Label3.Text = "User ID"
        '
        'tbUser
        '
        Me.tbUser.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tbUser.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.tbUser.Location = New System.Drawing.Point(138, 53)
        Me.tbUser.MaxLength = 5
        Me.tbUser.Name = "tbUser"
        Me.tbUser.Size = New System.Drawing.Size(174, 26)
        Me.tbUser.TabIndex = 1
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.BackColor = System.Drawing.Color.Transparent
        Me.Label1.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label1.Location = New System.Drawing.Point(12, 63)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(76, 18)
        Me.Label1.TabIndex = 103
        Me.Label1.Text = "User Name"
        '
        'tbName
        '
        Me.tbName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tbName.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.tbName.Location = New System.Drawing.Point(138, 86)
        Me.tbName.MaxLength = 25
        Me.tbName.Name = "tbName"
        Me.tbName.Size = New System.Drawing.Size(235, 26)
        Me.tbName.TabIndex = 2
        '
        'ComboBox1
        '
        Me.ComboBox1.FormattingEnabled = True
        Me.ComboBox1.Location = New System.Drawing.Point(137, 181)
        Me.ComboBox1.Name = "ComboBox1"
        Me.ComboBox1.Size = New System.Drawing.Size(175, 26)
        Me.ComboBox1.TabIndex = 121
        '
        'Label8
        '
        Me.Label8.AutoSize = True
        Me.Label8.BackColor = System.Drawing.Color.Transparent
        Me.Label8.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label8.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label8.Location = New System.Drawing.Point(12, 160)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(77, 18)
        Me.Label8.TabIndex = 122
        Me.Label8.Text = "User Group"
        '
        'cmdSave
        '
        Me.cmdSave.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdSave.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdSave.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdSave.Location = New System.Drawing.Point(544, 483)
        Me.cmdSave.Name = "cmdSave"
        Me.cmdSave.Size = New System.Drawing.Size(82, 27)
        Me.cmdSave.TabIndex = 269
        Me.cmdSave.Text = "Save"
        '
        'cmdExit
        '
        Me.cmdExit.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdExit.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdExit.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdExit.Location = New System.Drawing.Point(631, 483)
        Me.cmdExit.Name = "cmdExit"
        Me.cmdExit.Size = New System.Drawing.Size(82, 27)
        Me.cmdExit.TabIndex = 268
        Me.cmdExit.Text = "Exit"
        '
        'cmdRoles
        '
        Me.cmdRoles.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdRoles.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdRoles.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdRoles.Location = New System.Drawing.Point(456, 483)
        Me.cmdRoles.Name = "cmdRoles"
        Me.cmdRoles.Size = New System.Drawing.Size(82, 27)
        Me.cmdRoles.TabIndex = 269
        Me.cmdRoles.Text = "Roles"
        '
        'cmdDelete
        '
        Me.cmdDelete.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdDelete.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdDelete.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdDelete.Location = New System.Drawing.Point(368, 483)
        Me.cmdDelete.Name = "cmdDelete"
        Me.cmdDelete.Size = New System.Drawing.Size(82, 27)
        Me.cmdDelete.TabIndex = 269
        Me.cmdDelete.Text = "Delete"
        '
        'GroupPanel1
        '
        Me.GroupPanel1.CanvasColor = System.Drawing.SystemColors.Control
        Me.GroupPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007
        Me.GroupPanel1.Controls.Add(Me.GroupBox1)
        Me.GroupPanel1.Controls.Add(Me.cbActive)
        Me.GroupPanel1.Controls.Add(Me.Label4)
        Me.GroupPanel1.Controls.Add(Me.Label1)
        Me.GroupPanel1.Controls.Add(Me.Label8)
        Me.GroupPanel1.Controls.Add(Me.Label3)
        Me.GroupPanel1.Controls.Add(Me.Label2)
        Me.GroupPanel1.Controls.Add(Me.Label7)
        Me.GroupPanel1.Controls.Add(Me.Label6)
        Me.GroupPanel1.Controls.Add(Me.Label5)
        Me.GroupPanel1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.GroupPanel1.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.GroupPanel1.Location = New System.Drawing.Point(0, 0)
        Me.GroupPanel1.Name = "GroupPanel1"
        Me.GroupPanel1.Size = New System.Drawing.Size(734, 522)
        '
        '
        '
        Me.GroupPanel1.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2
        Me.GroupPanel1.Style.BackColorGradientAngle = 90
        Me.GroupPanel1.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground
        Me.GroupPanel1.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderBottomWidth = 1
        Me.GroupPanel1.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder
        Me.GroupPanel1.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderLeftWidth = 1
        Me.GroupPanel1.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderRightWidth = 1
        Me.GroupPanel1.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderTopWidth = 1
        Me.GroupPanel1.Style.CornerDiameter = 4
        Me.GroupPanel1.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded
        Me.GroupPanel1.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center
        Me.GroupPanel1.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText
        Me.GroupPanel1.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near
        Me.GroupPanel1.TabIndex = 270
        Me.GroupPanel1.Text = "Users and  Roles"
        '
        'frmUsers
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(7, 19)
        Me.BackColor = System.Drawing.SystemColors.ActiveCaption
        Me.ClientSize = New System.Drawing.Size(734, 522)
        Me.ControlBox = False
        Me.Controls.Add(Me.cmdDelete)
        Me.Controls.Add(Me.cmdRoles)
        Me.Controls.Add(Me.cmdSave)
        Me.Controls.Add(Me.cmdExit)
        Me.Controls.Add(Me.ComboBox1)
        Me.Controls.Add(Me.dgUsers)
        Me.Controls.Add(Me.dgShowroom)
        Me.Controls.Add(Me.tbUser)
        Me.Controls.Add(Me.tbName)
        Me.Controls.Add(Me.tbPassword)
        Me.Controls.Add(Me.lblNew)
        Me.Controls.Add(Me.GroupPanel1)
        Me.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.Location = New System.Drawing.Point(50, 50)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmUsers"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        CType(Me.dgUsers, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox1.PerformLayout()
        CType(Me.dgShowroom, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupPanel1.ResumeLayout(False)
        Me.GroupPanel1.PerformLayout()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

#End Region

    Private Sub ICproducts_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadUsers()
        LoadCompany(0)
    End Sub

    Private Sub LoadCompany(ByVal UID As Integer)
        Dim APdata As New APdataLogic
        Dim ds As DataSet
        ds = APdata.GetUserCompanyPrompt(UID)
        dgShowroom.DataSource = ds.Tables(0)
        APdata = Nothing
        With dgShowroom
            .TableStyles.Clear()
            .CaptionBackColor = System.Drawing.Color.SlateBlue
            .CaptionForeColor = System.Drawing.Color.LemonChiffon
            .AllowSorting = True
            .AlternatingBackColor = System.Drawing.Color.AliceBlue
            .ParentRowsBackColor = System.Drawing.Color.Lavender
            .ParentRowsForeColor = System.Drawing.Color.SlateBlue
            .HeaderBackColor = System.Drawing.Color.LemonChiffon
            .AllowNavigation = False
            .ParentRowsVisible = False
            .RowHeadersVisible = False
        End With

        Dim cm As CurrencyManager = BindingContext(dgShowroom.DataSource, dgShowroom.DataMember)
        Dim dv As DataView = cm.List
        dv.AllowNew = False
        dgformat(ds.Tables(0).Rows.Count)
    End Sub
    Private Sub dgformat(ByVal RowCount As Integer)
        Dim grdTableStyle As New DataGridTableStyle
        With grdTableStyle
            .AlternatingBackColor = Color.AliceBlue
            .HeaderFont = New Font("Tahoma", 8.0!, FontStyle.Bold)
            .MappingName = "COMPANY"
            .PreferredColumnWidth = 140
            .HeaderBackColor = Color.LightSlateGray
            .HeaderForeColor = Color.LightCyan
            .PreferredRowHeight = 15
            .RowHeadersVisible = False
            .RowHeaderWidth = 0
        End With
        Dim cs1 As DataGridColumnStyle
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 0
        cs1.MappingName = "COMPANYID"
        cs1.HeaderText = "ID"
        cs1.NullText = ""
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        Dim cs2 As DataGridBoolColumn
        cs2 = New DataGridBoolColumn
        cs2.Width = 20
        cs2.MappingName = "VALIDCOMPANY"
        cs2.ReadOnly = False
        cs2.FalseValue = 0
        cs2.TrueValue = 1
        cs2.AllowNull = False
        grdTableStyle.GridColumnStyles.Add(cs2)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.MappingName = "COMPANYNAME"
        cs1.HeaderText = "COMPANY"
        cs1.Width = 210
        cs1.NullText = ""
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        dgShowroom.TableStyles.Add(grdTableStyle)
    End Sub
    Private Sub LoadUsers()
        Dim APdata As New APdataLogic
        'Dim dss As DataSet
        'dss = APdata.GetUserGroupDetails
        'use()
        Dim dsw As DataSet = APdata.GetUserGroupDetails
        ComboBox1.DataSource = dsw.Tables(0)
        ComboBox1.ValueMember = "USERGROUPID"
        ComboBox1.DisplayMember = "USERGROUPNAME"
        ComboBox1.SelectedValue = 0


        Dim ds As DataSet
        ds = APdata.GetUserList
        dgUsers.DataSource = ds.Tables(0)
        APdata = Nothing
        With dgUsers
            .TableStyles.Clear()
            .CaptionBackColor = System.Drawing.Color.SlateBlue
            .CaptionForeColor = System.Drawing.Color.LemonChiffon
            .AllowSorting = True
            .AlternatingBackColor = System.Drawing.Color.AliceBlue
            .ParentRowsBackColor = System.Drawing.Color.Lavender
            .ParentRowsForeColor = System.Drawing.Color.SlateBlue
            .HeaderBackColor = System.Drawing.Color.LemonChiffon
            .AllowNavigation = False
            .ParentRowsVisible = False
            .RowHeadersVisible = False
        End With

        Dim cm As CurrencyManager = BindingContext(dgUsers.DataSource, dgUsers.DataMember)
        Dim dv As DataView = cm.List
        dv.AllowNew = False
        dgformat2(ds.Tables(0).Rows.Count)
    End Sub
    Private Sub dgformat2(ByVal RowCount As Integer)
        Dim grdTableStyle As New DataGridTableStyle
        With grdTableStyle
            .AlternatingBackColor = Color.AliceBlue
            .HeaderFont = New Font("Tahoma", 8.0!, FontStyle.Bold)
            .MappingName = "COMPANY"
            .PreferredColumnWidth = 140
            .HeaderBackColor = Color.LightSlateGray
            .HeaderForeColor = Color.LightCyan
            .PreferredRowHeight = 15
            .RowHeadersVisible = False
            .RowHeaderWidth = 0
        End With
        Dim cs1 As DataGridColumnStyle
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 0
        cs1.MappingName = "USERID"
        cs1.HeaderText = "ID"
        cs1.NullText = ""
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.MappingName = "USERCODE"
        cs1.HeaderText = "USERID"
        cs1.Width = 80
        cs1.NullText = ""
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        cs1 = New DataGridTextBoxColumn
        cs1.MappingName = "USERNAME"
        cs1.HeaderText = "NAME"
        cs1.Width = 200
        cs1.NullText = ""
        cs1.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs1)
        '
        dgUsers.TableStyles.Add(grdTableStyle)
    End Sub
    Private Sub tbUser_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles tbUser.Validated
        DisplayUser()
    End Sub
    Private Sub DisplayUser()
        If tbUser.Text.Trim <> "" Then
            Dim APdata As New APdataLogic
            Dim ds As DataSet
            ds = APdata.GetUserDetails(tbUser.Text.Trim)
            If ds.Tables(0).Rows.Count > 0 Then
                tbName.Text = ds.Tables(0).Rows(0).Item("UserName")
                tbPassword.Text = ds.Tables(0).Rows(0).Item("UserPassword")
                If ds.Tables(0).Rows(0).Item("UserStatus") = "ACTIVE" Then
                    cbActive.Checked = True
                Else
                    cbActive.Checked = False
                End If

                ComboBox1.SelectedValue = ds.Tables(0).Rows(0).Item("USERGROUPID")

                If ds.Tables(0).Rows(0).Item("UserRole") = "2" Then
                    rbAdmin.Checked = True
                Else
                    rbUser.Checked = True
                End If
                Tuser = ds.Tables(0).Rows(0).Item("UserID")
                '
                EditUserID = Tuser
                '
                LoadCompany(Tuser)
                lblNew.Text = ""
            Else
                lblNew.Text = "New User"
                Tuser = 0
            End If
            APdata = Nothing
        End If
    End Sub
    Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
        Me.Close()
    End Sub

    Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
        If tbUser.Text.Trim <> "" Then
            If tbName.Text.Trim <> "" Then
                If tbPassword.Text.Trim <> "" Then
                    Dim ds As DataSet
                    Dim mstat As String
                    If cbActive.Checked = True Then
                        mstat = "ACTIVE"
                    Else
                        mstat = "INACTIVE"
                    End If
                    Dim mrole As String
                    If rbUser.Checked = True Then
                        mrole = "1"
                    Else
                        mrole = "2"
                    End If
                    Dim mrow, drow As Integer
                    Dim cm As CurrencyManager = BindingContext(dgShowroom.DataSource, dgShowroom.DataMember)
                    Dim dv As DataView = cm.List
                    mrow = dv.Count

                    Dim sb As StringBuilder = New StringBuilder("")
                    Dim InvXml As String
                    sb.Append("<InvoiceDetails>")
                    sb.Append("<InvoiceData>")
                    Dim n As Integer
                    For n = 0 To mrow - 1
                        sb.Append("<InvLine>")
                        sb.Append("<CompanyID>" + CStr(dgShowroom.Item(n, 0)) + "</CompanyID>")
                        sb.Append("<IncludeCustomer>" + CStr(dgShowroom.Item(n, 1)) + "</IncludeCustomer>")
                        sb.Append("</InvLine>")
                    Next
                    sb.Append("</InvoiceData>")
                    sb.Append("</InvoiceDetails>")
                    InvXml = sb.ToString()
                    Dim APdata As New APdataLogic
                    Try
                        Tuser = APdata.UpdateUserDetails(Tuser, tbUser.Text, tbName.Text, tbPassword.Text, mstat, mrole, InvXml, ComboBox1.SelectedValue)
                        MsgBox("User Updated !", MsgBoxStyle.Information, "Inventory Manager")
                        APdata = Nothing
                        LoadUsers()
                        ClearScreen()
                        Exit Sub
                    Catch ex As Exception
                        APdata = Nothing
                        MsgBox("Unable to Update user. Try later !", MsgBoxStyle.Information, "Inventory Manager")
                        Exit Sub
                    End Try

                Else
                    MsgBox("Password should be entered !", MsgBoxStyle.Information, "Inventory Manager")
                    tbPassword.Focus()
                End If
            Else
                MsgBox("User name should be entered !", MsgBoxStyle.Information, "Inventory Manager")
                tbName.Focus()
            End If
        Else
            MsgBox("User ID should be entered !", MsgBoxStyle.Information, "Inventory Manager")
            tbUser.Focus()
        End If
    End Sub

    Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
        If tbUser.Text.Trim <> "" Then
            If MsgBox("Are you sure to delete this user?", MsgBoxStyle.YesNo, "Inventory Manager") = MsgBoxResult.Yes Then
                Dim ds As DataSet
                Dim mstat As String
                Dim APdata As New APdataLogic
                Try
                    APdata.DeleteUserDetails(Tuser)
                    MsgBox("User Deleted !", MsgBoxStyle.Information, "Inventory Manager")
                    APdata = Nothing
                    LoadUsers()
                    ClearScreen()
                    Exit Sub
                Catch
                    APdata = Nothing
                    MsgBox("Unable to Delete user. Try later !", MsgBoxStyle.Information, "Inventory Manager")
                    Exit Sub
                End Try
            Else
                Exit Sub
            End If
        Else
            MsgBox("User ID should be entered !", MsgBoxStyle.Information, "Inventory Manager")
            tbUser.Focus()
        End If
    End Sub
    Private Sub dgUsers_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgUsers.MouseUp
        Dim pt As New Point(e.X, e.Y)
        Dim hti As DataGrid.HitTestInfo = dgUsers.HitTest(pt)
        If hti.Type = DataGrid.HitTestType.Cell Then
            dgUsers.CurrentCell = New DataGridCell(hti.Row, hti.Column)
            dgUsers.Select(hti.Row)
            'Dim CurrentRow As Integer = dgUsers.CurrentCell.RowNumber
        End If
        Dim CurrentRow As Integer = dgUsers.CurrentCell.RowNumber
        tbUser.Text = dgUsers.Item(CurrentRow, 1)
        DisplayUser()
    End Sub
    Private Sub ClearScreen()
        tbUser.Clear()
        tbName.Clear()
        tbPassword.Clear()
        lblNew.Text = ""
        rbUser.Checked = True
        cbActive.Checked = False
        tbUser.Focus()
    End Sub
    Private Sub dgShowroom_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgShowroom.MouseUp
        Dim pt As New Point(e.X, e.Y)
        Dim hti As DataGrid.HitTestInfo = dgShowroom.HitTest(pt)
        If hti.Type = DataGrid.HitTestType.Cell Then
            dgShowroom.CurrentCell = New DataGridCell(hti.Row, hti.Column)
            dgShowroom.Select(hti.Row)
            Dim CurrentRow As Integer = dgShowroom.CurrentCell.RowNumber
            If dgShowroom.Item(CurrentRow, 1) = True Then
                dgShowroom.Item(CurrentRow, 1) = False
            Else
                dgShowroom.Item(CurrentRow, 1) = True
            End If
        End If
    End Sub
    'Private Sub dgUsers_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgUsers.DoubleClick
    '    Dim CurrentRow As Integer = dgUsers.CurrentCell.RowNumber
    '    tbUser.Text = dgUsers.Item(CurrentRow, 1)
    '    DisplayUser()
    'End Sub
    'Private Sub tpOptions_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    '    Dim APdata As New APdataLogic
    '    Dim ds As DataSet
    '    ds = APdata.GetUserCodeNameList()
    '    cmbUsers.DataSource = ds.Tables(0)
    '    cmbUsers.ValueMember = "UserID"
    '    cmbUsers.DisplayMember = "UserName"
    'End Sub
    'Private Sub cmbUsers_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
    '    If IsNumeric(cmbUsers.SelectedValue) Then
    '        Dim APdata As New APdataLogic
    '        Dim ds As DataSet
    '        ds = APdata.GetUserCompanies(cmbUsers.SelectedValue)
    '        cmbCompany.DataSource = ds.Tables(0)
    '        cmbCompany.ValueMember = "CompanyID"
    '        cmbCompany.DisplayMember = "CompanyName"
    '    End If
    'End Sub
    Private Sub cmdRoles_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRoles.Click
        uOptions = New frmUserSecurity
        uOptions.ShowDialog()
        Me.Close()
    End Sub
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    End Sub
End Class
